package com.ziri.quartz.cluster.quartzhandler;


import com.ziri.quartz.cluster.service.BaseLabelService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Slf4j
@Setter
@Component
public class ReflectionTest implements Job {

    @Autowired
    private BaseLabelService baseLabelService;
    private Integer minId;
    private Integer maxId;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{

            log.info(context.getJobDetail().getKey().getName()+" start, minId:"+String.valueOf(minId)+"，maxId:"+String.valueOf(maxId)+"，labelCount:"+baseLabelService.getAllLabel().size()
                    +" -- "+simpleDateFormat.format(new Date()));
            Thread.sleep(4000);
            log.info(context.getJobDetail().getKey().getName()+" end");
        }catch (Exception e){

        }

    }
}
